const rl = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
})

let input = [];
let grid = [];
let visited = [];
let n = 0, m = 0;
let ans = 0;
let maxArea = 0;

const dx = [0, 0, 1, -1];
const dy = [1, -1, 0, 0];

rl.on('line', (line) => {
  input.push(line.split(' '));
}).on('close', () => {
  processInput(input);

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      if (!visited[i][j] && grid[i][j] === 1) {
        ans = 0;
        dfs([i, j]);
      }
    }
  }
  console.log(maxArea);
})


function processInput(input) {
  [n, m] = input[0].map(Number);
  grid = input.slice(1).map(row => row.map(Number));  
  visited = new Array(n).fill(0).map(() => new Array(m).fill(false));
}

function dfs(start) {
  ans++;
  maxArea = Math.max(maxArea, ans);
  let [x, y] = start;
  visited[x][y] = true;

  for (let i = 0; i < 4; i++) {
    let [nx, ny] = [x + dx[i], y + dy[i]];
    if (nx >= 0 && nx < n && ny >= 0 && ny < m && !visited[nx][ny] && grid[nx][ny] === 1) {
      dfs([nx, ny]);
    }
  }
}